package br.com.mucceli.politicapopular.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author mucceli
 */
@Entity
@Table(name = "PROMESSA")
@NamedQueries({
    @NamedQuery(name = "Promessa.findAll", query = "SELECT p FROM Promessa p"),
    @NamedQuery(name = "Promessa.findByIdPromessa", query = "SELECT p FROM Promessa p WHERE p.idPromessa = :idPromessa")})
public class Promessa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_PROMESSA")
    private Integer idPromessa;
    @Lob
    @Column(name = "ARQUIVO")
    private byte[] arquivo;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Column(name = "DESCRICAO")
    private byte[] descricao;
    @JoinColumn(name = "FK_ELEICAO", referencedColumnName = "ID_ELEICAO")
    @ManyToOne(optional = false)
    private Eleicao fkEleicao;

    public Promessa() {
    }

    public Promessa(Integer idPromessa) {
        this.idPromessa = idPromessa;
    }

    public Promessa(Integer idPromessa, byte[] descricao) {
        this.idPromessa = idPromessa;
        this.descricao = descricao;
    }

    public Integer getIdPromessa() {
        return idPromessa;
    }

    public void setIdPromessa(Integer idPromessa) {
        this.idPromessa = idPromessa;
    }

    public byte[] getArquivo() {
        return arquivo;
    }

    public void setArquivo(byte[] arquivo) {
        this.arquivo = arquivo;
    }

    public byte[] getDescricao() {
        return descricao;
    }

    public void setDescricao(byte[] descricao) {
        this.descricao = descricao;
    }

    public Eleicao getFkEleicao() {
        return fkEleicao;
    }

    public void setFkEleicao(Eleicao fkEleicao) {
        this.fkEleicao = fkEleicao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPromessa != null ? idPromessa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Promessa)) {
            return false;
        }
        Promessa other = (Promessa) object;
        if ((this.idPromessa == null && other.idPromessa != null) || (this.idPromessa != null && !this.idPromessa.equals(other.idPromessa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.mavenproject1.Promessa[ idPromessa=" + idPromessa + " ]";
    }
    
}
